home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14558 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  45 lines

  1. Path: ix.netcom.com!news
  2. From: jlilley@ix.netcom.com (John Lilley)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: record
  5. Date: 30 Mar 1996 23:49:21 GMT
  6. Organization: Netcom
  7. Message-ID: <4jkha1$i4b@dfw-ixnews6.ix.netcom.com>
  8. References: <4jhr5v$6dg@news-e2b.gnn.com>
  9. NNTP-Posting-Host: den-co15-25.ix.netcom.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-NETCOM-Date: Sat Mar 30  5:49:21 PM CST 1996
  13. X-Newsreader: WinVN 0.99.7
  14.  
  15. In article <4jhr5v$6dg@news-e2b.gnn.com>, BMette@gnn.com says...
  16. >
  17. >How do I send a 'record' to a file?
  18. >        I am using...
  19. >
  20. >struct application {...} app;
  21. >
  22. >and
  23. >
  24. >handle = open("DOA_APP.TXT", O_CREAT | O_RDWR | O_TEXT);
  25. >   write(...);
  26. >   ...
  27. >   close(handle);
  28. >
  29. >but i want to just put it all at once...
  30. >        if i cannot put it all at once how do i place line breaks 
  31. >after each line?
  32.  
  33.  
  34. Try:
  35.     write(handle, (void*)&app, sizeof(app));
  36.  
  37. But hey!  This is a C++ newsgroup!  Use iostreams -- define your 
  38. struct as a class and supply an operator << to dump it to a stream.
  39.  
  40. john lilley
  41.  
  42.  
  43.  
  44.  
  45.